package com.guhecloud.step.definition.test.order;


import com.guhecloud.step.definition.runtime.IDecideStepsExt;
import com.guhecloud.step.definition.runtime.IDomainModel;
import com.guhecloud.step.definition.runtime.annotation.Extension;

import java.util.*;

@Extension(code = KaPartner.CODE, name = "KA业务前台对所有流程的编排", value = "kaDecideStepsExt")
public class DecideStepsExt implements IDecideStepsExt {
    private static final List<String> emptySteps = Collections.emptyList();
    @Override
    public List<String> decideSteps(IDomainModel model, String activityCode) {
        List<String> steps = stepsRegistry.get(activityCode);
        if (steps == null) {
            return emptySteps;
        }

        return steps;
    }
    private static Map<String, List<String>> stepsRegistry = new HashMap<>();
    static {
        // 接单的步骤
        List<String> submitOrderSteps = new ArrayList<>();
        stepsRegistry.put(Steps.SubmitOrder.Activity, submitOrderSteps);
        submitOrderSteps.add(Steps.SubmitOrder.BasicStep);
        submitOrderSteps.add(Steps.SubmitOrder.PersistStep);


        List<String> startProcessInstanceSteps = new ArrayList<>();
        stepsRegistry.put(Steps.StartProcessInstance.Activity, startProcessInstanceSteps);
        startProcessInstanceSteps.add(Steps.StartProcessInstance.BasicStep);
        startProcessInstanceSteps.add(Steps.StartProcessInstance.PersistStep);
    }
}
